﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Dack_Web2
{
    public partial class ThongTinGioHang : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (CurrentContext.IsLogged)
                {
                    Dack_Web2.User US = Dack_Web2.User.FromId(CurrentContext.UserName);
                    //string sql = string.Format("select * from GioHang where MaKhachHang = {0}",US.MaUser);
                    string sql = "select s.TenSanPham, g.SoLuong, g.TinhTrang, g.DiaChiGiaoHang, ((s.GiaSanPham - (s.GiaSanPham / 100) * d.Giam)*g.SoLuong) as TongCong from [GioHang] g, [Deal] d, [SanPham] s where g.MaDeal = d.MaDeal and d.MaSanPham = s.MaSanPham and g.MaKhachHang =" + US.MaUser;
                    gvGioHang.DataSource = Sql_DataProvider.SQL_ExecuteTable(sql);
                    gvGioHang.DataBind();
                }
                else
                {
                    Response.Redirect("~/Login.aspx");
                }
            }
        }
    }
}